<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 500px;
            height: 40px;
            margin: 100px auto;
            border: 2px solid rgb(0, 139, 255);
        }
        
        .box a {
            float: right;
            height: 100%;
            width: 100px;
            text-decoration: none;
            font-size: 20px;
            line-height: 40px;
            text-align: center;
            color: #fff;
            background-color: rgb(0, 139, 255);
        }
        
        .box input {
            float: left;
            width: 398px;
            height: 38px;
            outline: none;
            border: 0;
            color: gray;
            padding-left: 2px;
        }
    </style>
</head>

<body>
    <div class="box">
        <input type="text" value="手机">
        <a href="#">搜索</a>

    </div>
    <script>
        var key = document.querySelector('input');
        key.onfocus = function() {
            if (this.value == '手机') {
                this.value = '';
            }
            this.style.color = '#333'
        }
        key.onblur = function() {
            if (this.value == '') {
                this.value = '手机';
                this.style.color = '#999'
            }
        }
    </script>
</body>

</html>